package com.common.dataservice.service.impl;



import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.common.dataservice.entity.User;
import com.common.dataservice.mapper.UserMapper;
import com.common.dataservice.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DS("slave")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {


    @Override
//     @DS("master")//这里必须包一层，不能调用mp默认的插入，因为会走到从库去
    public void addUser(User user) {
        baseMapper.insert(user);
    }

    @Override
    public List<User> getAll() {
        List<User> users = baseMapper.selectList(new EntityWrapper<>());
        return users;
    }
}
